<?php


namespace App\Models;


use Illuminate\Database\Eloquent\SoftDeletes;

class ImAccount extends BaseModel
{
    use SoftDeletes;
    protected $table = 'im_account';
    const ADMIN_ROLE_ID = 1;//超级管理员角色ID

    //获取生日
    public function getBirthdayAttribute($value)
    {
        if ($value > 0) {
            return date('Y-m-d H:i:s', $value);
        } else {
            return '';
        }
    }

    //账号角色
    public function accountRole()
    {
        return $this->belongsTo(ImAccountRoles::class, 'role_id', 'id')
            ->select(['id', 'name']);
    }
}
